export default {
	beforeMount(el, binding) {
		const urlParams = new URLSearchParams(window.location.search);
		const pagetypeValue = urlParams.get('pageType');
		const { value } = binding;
		let list = JSON.parse(localStorage.getItem('portalResourceList'));
		// if (process.env.NODE_ENV !== 'development') {
			let flg = true;
			for (var i = 0; i < value.permis.length; i++) {
				if (list.indexOf(value.permis[i]) == -1) {
					flg = false;
					break;
				}
			}

            var inputs = el.querySelectorAll('input');
            console.log(inputs)

			if (value.businessFlag) {
				if (pagetypeValue != 'edit' || !flg) {
                    // pointer-events: none
                    el.classList.add('is-disabled')
                    inputs.forEach(function(input) {
                        input.disabled = true;
                    });
				}
			} else {
				if (!flg) {
                    el.classList.add('is-disabled')
					inputs.forEach(function(input) {
                        input.disabled = true;
                    });
				}
			}


			if (value.isHiden && !flg) {
				el.parentNode && el.parentNode.removeChild(el);
			}
		// }
	},
};
